package com.common.context;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationEvent;

public class ApplicationContextUtil {

    private ApplicationContextUtil() {
    }

    private static ApplicationContext context;
    private static String appRealPath;

    public static String getAppRealPath() {
        return appRealPath;
    }

    public static void setAppRealPath(String path) {
        appRealPath = path;
    }

    public static void setApplicationContext(ApplicationContext acx) {
        context = acx;
    }

    public static ApplicationContext getApplicationContext() {
        return context;
    }

    public static Object getBean(String beanId) throws BeansException {
        return context.getBean(beanId);
    }

    public static void publishEvent(ApplicationEvent event) {
        context.publishEvent(event);
    }
}